#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int T,n,m,len,v_max;
int d[N],a[N],v[N],p[N];
vector<pair<int,int>> areas;
int cnt[N];
vector<pair<int,int>> hbzleft;
/*
Such a easy physics problem (I am a PhOer) qwq
16:15 first answer ok for all cases
*/
stack<pair<int,int>> st;
bool cmp(pair<int,int> p1,pair<int,int> p2)
{
    if(p1.first!=p2.first)
    {
        return p1.first<p2.first;
    }
    return p1.second<p2.second;
}
bool contain(pair<int,int> p1,pair<int,int> p2)
{
    return p1.first>=p2.first && p1.second<=p2.second;
}
int wash_up()
{
    //cout<<"--------"<<endl;
    sort(areas.begin(),areas.end(),cmp);
    for(auto i:areas)
    {
        //cout<<i.first<<" "<<i.second<<endl;
        if(st.size())
        {
            while(st.size()&&contain(i,st.top()))
            {
                //cout<<"brc 1"<<endl;
                //cout<<"pop "<<st.top().first<<" "<<st.top().second<<endl;
                st.pop();
            }
            if(st.size()&&!contain(i,st.top())&&!contain(st.top(),i)) st.push(i);
            else if(st.empty()) st.push(i);
        }
        else
        {
            st.push(i);
        }
    }
    
    while(!st.empty())
    {
        //cout<<st.top().first<<" "<<st.top().second<<endl;
        hbzleft.push_back(st.top());
        st.pop();
    }
    reverse(hbzleft.begin(),hbzleft.end());
    
    int cnt=0;
    bool flg=false;
    if(hbzleft.empty()) return 0;
    for(int j=0;j<hbzleft.size()-1;j++)
    {
        if(hbzleft[j+1].first<=hbzleft[j].second)
        {
            flg=true;
        }
        else
        {
            if(flg)
            {
                cnt++;
                flg=false;
            }
        }
    }
    if(flg) cnt++;
    //ut<<cnt<<endl;
    
    return hbzleft.size()-cnt;
}
void initialize()
{
    hbzleft.clear();
    areas.clear();
    while(st.size()) st.pop();
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin>>T;
    while(T--)
    {
        initialize();
        cin>>n>>m>>len>>v_max;
        
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        sort(p+1,p+m+1);
        int ans1=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]>0)
            {
                int st,ed;
                //accelerate
                bool flg=true;
                if(v[i]>v_max)
                {
                    //out of speed at the beginning
                    if(p[m]>=d[i])
                    {
                        ans1++;
                        st=lower_bound(p+1,p+m+1,d[i])-p;

                        ed=m;
                        flg=false;
                        
                        
                        areas.push_back(make_pair(st,ed));
                       // cout<<d[i]<<" "<<st<<" "<<ed<<" "<<endl;
                        continue;
                    }
                    else
                    {
                        continue;
                    }
                    
                }
                double distance=(long double)(v_max*v_max-v[i]*v[i])/(2*a[i]);
                int dst=floor(distance)+d[i];
                if(dst>len)
                {
                    //out of range
                    continue;
                }
                
                st=upper_bound(p+1,p+m+1,dst)-p;
                if(st==m+1)
                {
                    continue;
                }
                ed=m;
                if(st<=ed&&flg)
                {
                    ans1++;
                }
               // cout<<dst<<" "<<d[i]<<" "<<st<<" "<<ed<<" "<<endl;
                areas.push_back(make_pair(st,ed));
            }
            else if(a[i]<0)
            {
                //decelerate
                int st,ed;
                if(v[i]<=v_max)
                {
                    continue;
                }
                double distance=(double)(v[i]*v[i]-v_max*v_max)/(-2*a[i]);
                int dst=ceil(distance)+d[i];
                //cout<<dst<<endl;
                st=lower_bound(p+1,p+m+1,d[i])-p;
                
                ed=lower_bound(p+1,p+m+1,dst)-p-1;
                //cout<<dst<<" "<<d[i]<<" "<<st<<" "<<ed<<" "<<endl;
                
                if(st<=ed) ans1++,areas.push_back(make_pair(st,ed));
                
            }
            else
            {
                if(v[i]>v_max)
                {
                    int st=lower_bound(p+1,p+m+1,d[i])-p;
                    if(st>m)
                    {
                        continue;
                    }
                    ans1++;
                    int ed=m;
                    //cout<<d[i]<<" "<<st<<" "<<ed<<" "<<endl;
                    areas.push_back(make_pair(st,ed));
                    
                }
            }
        }
        /*
        for(auto i:areas)
        {
            cout<<i.first<<" "<<i.second<<endl;
        }
        */
       assert(areas.size()==ans1);
        cout<<ans1<<" ";
        cout<<m-wash_up()<<endl;
    }
    
    return 0;
}